package com.server.questionbank.snframe.controller.Course.pojo.Exercises;

import com.server.questionbank.snframe.domain.Course.Chapter.UpdateChapter;
import com.server.questionbank.snframe.domain.Homework.TExercises;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

@Data
public class UpdateExercises {
    private Long exercisesId;
    private Long chapterId;
    private Long courseId;
    private String title;
    private String questionStem;
    private String exerciseType;
    private Integer difficulty;
    private String difficultyText;
    private String topicStatus;
    private Long accuracy;
    private Long challengeNum;
    private String forPractice;
    private String forTest;
    private String dataType;
    private Long createBy;
    private String createDate;
    private Long updateBy;
    private String updateDate;
    private String eleRemark;
    private List<UpdateQuestion> questions;
    private List<UpdateKnowledge> knowledges;
    private UpdateChapter chapterInfo;

    public TExercises toTExercises() {
        return new TExercises(
                exercisesId,
                chapterId,
                courseId,
                title,
                questionStem,
                exerciseType,
                difficulty,
                difficultyText,
                topicStatus,
                accuracy,
                challengeNum,
                forPractice,
                forTest,
                dataType,
                createBy,
                createDate,
                null,
                updateBy,
                updateDate,
                eleRemark,
                questions.stream().map(uk -> uk.toQuestion()).collect(Collectors.toList()),
                null,
                null,
                null
        );
    }
}
